<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - Lua 5.3.5 - src/lobject.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - lobject.c</td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">Lua 5.3.5</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">205</td>
            <td class="headerCovTableEntry">224</td>
            <td class="headerCovTableEntryHi">91.5 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2019-06-13 19:44:17</td>
            <td></td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<span class="lineNum">       1 </span>            : /*
<span class="lineNum">       2 </span>            : ** $Id: lobject.c,v 2.113.1.1 2017/04/19 17:29:57 roberto Exp $
<span class="lineNum">       3 </span>            : ** Some generic functions over Lua objects
<span class="lineNum">       4 </span>            : ** See Copyright Notice in lua.h
<span class="lineNum">       5 </span>            : */
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : #define lobject_c
<span class="lineNum">       8 </span>            : #define LUA_CORE
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : #include &quot;lprefix.h&quot;
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : 
<span class="lineNum">      13 </span>            : #include &lt;locale.h&gt;
<span class="lineNum">      14 </span>            : #include &lt;math.h&gt;
<span class="lineNum">      15 </span>            : #include &lt;stdarg.h&gt;
<span class="lineNum">      16 </span>            : #include &lt;stdio.h&gt;
<span class="lineNum">      17 </span>            : #include &lt;stdlib.h&gt;
<span class="lineNum">      18 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      19 </span>            : 
<span class="lineNum">      20 </span>            : #include &quot;lua.h&quot;
<span class="lineNum">      21 </span>            : 
<span class="lineNum">      22 </span>            : #include &quot;lctype.h&quot;
<span class="lineNum">      23 </span>            : #include &quot;ldebug.h&quot;
<span class="lineNum">      24 </span>            : #include &quot;ldo.h&quot;
<span class="lineNum">      25 </span>            : #include &quot;lmem.h&quot;
<span class="lineNum">      26 </span>            : #include &quot;lobject.h&quot;
<span class="lineNum">      27 </span>            : #include &quot;lstate.h&quot;
<span class="lineNum">      28 </span>            : #include &quot;lstring.h&quot;
<span class="lineNum">      29 </span>            : #include &quot;lvm.h&quot;
<span class="lineNum">      30 </span>            : 
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : 
<span class="lineNum">      33 </span>            : LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT};
<span class="lineNum">      34 </span>            : 
<span class="lineNum">      35 </span>            : 
<span class="lineNum">      36 </span>            : /*
<span class="lineNum">      37 </span>            : ** converts an integer to a &quot;floating point byte&quot;, represented as
<span class="lineNum">      38 </span>            : ** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
<span class="lineNum">      39 </span>            : ** eeeee != 0 and (xxx) otherwise.
<span class="lineNum">      40 </span>            : */
<span class="lineNum">      41 </span><span class="lineCov">       1386 : int luaO_int2fb (unsigned int x) {</span>
<span class="lineNum">      42 </span><span class="lineCov">       1386 :   int e = 0;  /* exponent */</span>
<span class="lineNum">      43 </span><span class="lineCov">       1386 :   if (x &lt; 8) return x;</span>
<span class="lineNum">      44 </span><span class="lineCov">          6 :   while (x &gt;= (8 &lt;&lt; 4)) {  /* coarse steps */</span>
<span class="lineNum">      45 </span><span class="lineCov">          1 :     x = (x + 0xf) &gt;&gt; 4;  /* x = ceil(x / 16) */</span>
<span class="lineNum">      46 </span><span class="lineCov">          1 :     e += 4;</span>
<span class="lineNum">      47 </span>            :   }
<span class="lineNum">      48 </span><span class="lineCov">          8 :   while (x &gt;= (8 &lt;&lt; 1)) {  /* fine steps */</span>
<span class="lineNum">      49 </span><span class="lineCov">          3 :     x = (x + 1) &gt;&gt; 1;  /* x = ceil(x / 2) */</span>
<span class="lineNum">      50 </span><span class="lineCov">          3 :     e++;</span>
<span class="lineNum">      51 </span>            :   }
<span class="lineNum">      52 </span><span class="lineCov">          5 :   return ((e+1) &lt;&lt; 3) | (cast_int(x) - 8);</span>
<span class="lineNum">      53 </span>            : }
<span class="lineNum">      54 </span>            : 
<span class="lineNum">      55 </span>            : 
<span class="lineNum">      56 </span>            : /* converts back */
<span class="lineNum">      57 </span><span class="lineCov">        524 : int luaO_fb2int (int x) {</span>
<span class="lineNum">      58 </span><span class="lineCov">        524 :   return (x &lt; 8) ? x : ((x &amp; 7) + 8) &lt;&lt; ((x &gt;&gt; 3) - 1);</span>
<span class="lineNum">      59 </span>            : }
<span class="lineNum">      60 </span>            : 
<span class="lineNum">      61 </span>            : 
<span class="lineNum">      62 </span>            : /*
<span class="lineNum">      63 </span>            : ** Computes ceil(log2(x))
<span class="lineNum">      64 </span>            : */
<span class="lineNum">      65 </span><span class="lineCov">      29283 : int luaO_ceillog2 (unsigned int x) {</span>
<span class="lineNum">      66 </span>            :   static const lu_byte log_2[256] = {  /* log_2[i] = ceil(log2(i - 1)) */
<span class="lineNum">      67 </span>            :     0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
<span class="lineNum">      68 </span>            :     6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
<span class="lineNum">      69 </span>            :     7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
<span class="lineNum">      70 </span>            :     7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
<span class="lineNum">      71 </span>            :     8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
<span class="lineNum">      72 </span>            :     8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
<span class="lineNum">      73 </span>            :     8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
<span class="lineNum">      74 </span>            :     8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
<span class="lineNum">      75 </span>            :   };
<span class="lineNum">      76 </span><span class="lineCov">      29283 :   int l = 0;</span>
<span class="lineNum">      77 </span><span class="lineCov">      29283 :   x--;</span>
<span class="lineNum">      78 </span><span class="lineCov">      29290 :   while (x &gt;= 256) { l += 8; x &gt;&gt;= 8; }</span>
<span class="lineNum">      79 </span><span class="lineCov">      29283 :   return l + log_2[x];</span>
<span class="lineNum">      80 </span>            : }
<span class="lineNum">      81 </span>            : 
<span class="lineNum">      82 </span>            : 
<span class="lineNum">      83 </span><span class="lineCov">        152 : static lua_Integer intarith (lua_State *L, int op, lua_Integer v1,</span>
<span class="lineNum">      84 </span>            :                                                    lua_Integer v2) {
<span class="lineNum">      85 </span><span class="lineCov">        152 :   switch (op) {</span>
<span class="lineNum">      86 </span><span class="lineCov">          4 :     case LUA_OPADD: return intop(+, v1, v2);</span>
<span class="lineNum">      87 </span><span class="lineCov">          2 :     case LUA_OPSUB:return intop(-, v1, v2);</span>
<span class="lineNum">      88 </span><span class="lineCov">          1 :     case LUA_OPMUL:return intop(*, v1, v2);</span>
<span class="lineNum">      89 </span><span class="lineCov">          1 :     case LUA_OPMOD: return luaV_mod(L, v1, v2);</span>
<span class="lineNum">      90 </span><span class="lineCov">          3 :     case LUA_OPIDIV: return luaV_div(L, v1, v2);</span>
<span class="lineNum">      91 </span><span class="lineCov">          1 :     case LUA_OPBAND: return intop(&amp;, v1, v2);</span>
<span class="lineNum">      92 </span><span class="lineCov">          1 :     case LUA_OPBOR: return intop(|, v1, v2);</span>
<span class="lineNum">      93 </span><span class="lineCov">          1 :     case LUA_OPBXOR: return intop(^, v1, v2);</span>
<span class="lineNum">      94 </span><span class="lineCov">          1 :     case LUA_OPSHL: return luaV_shiftl(v1, v2);</span>
<span class="lineNum">      95 </span><span class="lineCov">          1 :     case LUA_OPSHR: return luaV_shiftl(v1, -v2);</span>
<span class="lineNum">      96 </span><span class="lineCov">        135 :     case LUA_OPUNM: return intop(-, 0, v1);</span>
<span class="lineNum">      97 </span><span class="lineCov">          1 :     case LUA_OPBNOT: return intop(^, ~l_castS2U(0), v1);</span>
<span class="lineNum">      98 </span><span class="lineNoCov">          0 :     default: lua_assert(0); return 0;</span>
<span class="lineNum">      99 </span>            :   }
<span class="lineNum">     100 </span>            : }
<span class="lineNum">     101 </span>            : 
<span class="lineNum">     102 </span>            : 
<span class="lineNum">     103 </span><span class="lineCov">         31 : static lua_Number numarith (lua_State *L, int op, lua_Number v1,</span>
<span class="lineNum">     104 </span>            :                                                   lua_Number v2) {
<span class="lineNum">     105 </span><span class="lineCov">         31 :   switch (op) {</span>
<span class="lineNum">     106 </span><span class="lineCov">          2 :     case LUA_OPADD: return luai_numadd(L, v1, v2);</span>
<span class="lineNum">     107 </span><span class="lineCov">          1 :     case LUA_OPSUB: return luai_numsub(L, v1, v2);</span>
<span class="lineNum">     108 </span><span class="lineCov">          3 :     case LUA_OPMUL: return luai_nummul(L, v1, v2);</span>
<span class="lineNum">     109 </span><span class="lineCov">          4 :     case LUA_OPDIV: return luai_numdiv(L, v1, v2);</span>
<span class="lineNum">     110 </span><span class="lineCov">          3 :     case LUA_OPPOW: return luai_numpow(L, v1, v2);</span>
<span class="lineNum">     111 </span><span class="lineCov">          1 :     case LUA_OPIDIV: return luai_numidiv(L, v1, v2);</span>
<span class="lineNum">     112 </span><span class="lineCov">         16 :     case LUA_OPUNM: return luai_numunm(L, v1);</span>
<span class="lineNum">     113 </span><span class="lineCov">          1 :     case LUA_OPMOD: {</span>
<span class="lineNum">     114 </span>            :       lua_Number m;
<span class="lineNum">     115 </span><span class="lineCov">          1 :       luai_nummod(L, v1, v2, m);</span>
<span class="lineNum">     116 </span><span class="lineCov">          1 :       return m;</span>
<span class="lineNum">     117 </span>            :     }
<span class="lineNum">     118 </span><span class="lineNoCov">          0 :     default: lua_assert(0); return 0;</span>
<span class="lineNum">     119 </span>            :   }
<span class="lineNum">     120 </span>            : }
<span class="lineNum">     121 </span>            : 
<span class="lineNum">     122 </span>            : 
<span class="lineNum">     123 </span><span class="lineCov">        183 : void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,</span>
<span class="lineNum">     124 </span>            :                  TValue *res) {
<span class="lineNum">     125 </span><span class="lineCov">        183 :   switch (op) {</span>
<span class="lineNum">     126 </span><span class="lineCov">          6 :     case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:</span>
<span class="lineNum">     127 </span>            :     case LUA_OPSHL: case LUA_OPSHR:
<span class="lineNum">     128 </span>            :     case LUA_OPBNOT: {  /* operate only on integers */
<span class="lineNum">     129 </span>            :       lua_Integer i1; lua_Integer i2;
<span class="lineNum">     130 </span><span class="lineCov">          6 :       if (tointeger(p1, &amp;i1) &amp;&amp; tointeger(p2, &amp;i2)) {</span>
<span class="lineNum">     131 </span><span class="lineCov">          6 :         setivalue(res, intarith(L, op, i1, i2));</span>
<span class="lineNum">     132 </span><span class="lineCov">          6 :         return;</span>
<span class="lineNum">     133 </span>            :       }
<span class="lineNum">     134 </span>            :       else break;  /* go to the end */
<span class="lineNum">     135 </span>            :     }
<span class="lineNum">     136 </span><span class="lineCov">          7 :     case LUA_OPDIV: case LUA_OPPOW: {  /* operate only on floats */</span>
<span class="lineNum">     137 </span>            :       lua_Number n1; lua_Number n2;
<span class="lineNum">     138 </span><span class="lineCov">          7 :       if (tonumber(p1, &amp;n1) &amp;&amp; tonumber(p2, &amp;n2)) {</span>
<span class="lineNum">     139 </span><span class="lineCov">          7 :         setfltvalue(res, numarith(L, op, n1, n2));</span>
<span class="lineNum">     140 </span><span class="lineCov">          7 :         return;</span>
<span class="lineNum">     141 </span>            :       }
<span class="lineNum">     142 </span>            :       else break;  /* go to the end */
<span class="lineNum">     143 </span>            :     }
<span class="lineNum">     144 </span><span class="lineCov">        170 :     default: {  /* other operations */</span>
<span class="lineNum">     145 </span>            :       lua_Number n1; lua_Number n2;
<span class="lineNum">     146 </span><span class="lineCov">        170 :       if (ttisinteger(p1) &amp;&amp; ttisinteger(p2)) {</span>
<span class="lineNum">     147 </span><span class="lineCov">        146 :         setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2)));</span>
<span class="lineNum">     148 </span><span class="lineCov">        170 :         return;</span>
<span class="lineNum">     149 </span>            :       }
<span class="lineNum">     150 </span><span class="lineCov">         24 :       else if (tonumber(p1, &amp;n1) &amp;&amp; tonumber(p2, &amp;n2)) {</span>
<span class="lineNum">     151 </span><span class="lineCov">         24 :         setfltvalue(res, numarith(L, op, n1, n2));</span>
<span class="lineNum">     152 </span><span class="lineCov">         24 :         return;</span>
<span class="lineNum">     153 </span>            :       }
<span class="lineNum">     154 </span>            :       else break;  /* go to the end */
<span class="lineNum">     155 </span>            :     }
<span class="lineNum">     156 </span>            :   }
<span class="lineNum">     157 </span>            :   /* could not perform raw operation; try metamethod */
<span class="lineNum">     158 </span>            :   lua_assert(L != NULL);  /* should not fail when folding (compile time) */
<span class="lineNum">     159 </span><span class="lineNoCov">          0 :   luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD));</span>
<span class="lineNum">     160 </span>            : }
<span class="lineNum">     161 </span>            : 
<span class="lineNum">     162 </span>            : 
<span class="lineNum">     163 </span><span class="lineCov">        712 : int luaO_hexavalue (int c) {</span>
<span class="lineNum">     164 </span><span class="lineCov">        712 :   if (lisdigit(c)) return c - '0';</span>
<span class="lineNum">     165 </span><span class="lineCov">        249 :   else return (ltolower(c) - 'a') + 10;</span>
<span class="lineNum">     166 </span>            : }
<span class="lineNum">     167 </span>            : 
<span class="lineNum">     168 </span>            : 
<span class="lineNum">     169 </span><span class="lineCov">       3606 : static int isneg (const char **s) {</span>
<span class="lineNum">     170 </span><span class="lineCov">       3606 :   if (**s == '-') { (*s)++; return 1; }</span>
<span class="lineNum">     171 </span><span class="lineCov">       3581 :   else if (**s == '+') (*s)++;</span>
<span class="lineNum">     172 </span><span class="lineCov">       3581 :   return 0;</span>
<span class="lineNum">     173 </span>            : }
<span class="lineNum">     174 </span>            : 
<span class="lineNum">     175 </span>            : 
<span class="lineNum">     176 </span>            : 
<span class="lineNum">     177 </span>            : /*
<span class="lineNum">     178 </span>            : ** {==================================================================
<span class="lineNum">     179 </span>            : ** Lua's implementation for 'lua_strx2number'
<span class="lineNum">     180 </span>            : ** ===================================================================
<span class="lineNum">     181 </span>            : */
<span class="lineNum">     182 </span>            : 
<span class="lineNum">     183 </span>            : #if !defined(lua_strx2number)
<span class="lineNum">     184 </span>            : 
<span class="lineNum">     185 </span>            : /* maximum number of significant digits to read (to avoid overflows
<span class="lineNum">     186 </span>            :    even with single floats) */
<span class="lineNum">     187 </span>            : #define MAXSIGDIG       30
<span class="lineNum">     188 </span>            : 
<span class="lineNum">     189 </span>            : /*
<span class="lineNum">     190 </span>            : ** convert an hexadecimal numeric string to a number, following
<span class="lineNum">     191 </span>            : ** C99 specification for 'strtod'
<span class="lineNum">     192 </span>            : */
<span class="lineNum">     193 </span>            : static lua_Number lua_strx2number (const char *s, char **endptr) {
<span class="lineNum">     194 </span>            :   int dot = lua_getlocaledecpoint();
<span class="lineNum">     195 </span>            :   lua_Number r = 0.0;  /* result (accumulator) */
<span class="lineNum">     196 </span>            :   int sigdig = 0;  /* number of significant digits */
<span class="lineNum">     197 </span>            :   int nosigdig = 0;  /* number of non-significant digits */
<span class="lineNum">     198 </span>            :   int e = 0;  /* exponent correction */
<span class="lineNum">     199 </span>            :   int neg;  /* 1 if number is negative */
<span class="lineNum">     200 </span>            :   int hasdot = 0;  /* true after seen a dot */
<span class="lineNum">     201 </span>            :   *endptr = cast(char *, s);  /* nothing is valid yet */
<span class="lineNum">     202 </span>            :   while (lisspace(cast_uchar(*s))) s++;  /* skip initial spaces */
<span class="lineNum">     203 </span>            :   neg = isneg(&amp;s);  /* check signal */
<span class="lineNum">     204 </span>            :   if (!(*s == '0' &amp;&amp; (*(s + 1) == 'x' || *(s + 1) == 'X')))  /* check '0x' */
<span class="lineNum">     205 </span>            :     return 0.0;  /* invalid format (no '0x') */
<span class="lineNum">     206 </span>            :   for (s += 2; ; s++) {  /* skip '0x' and read numeral */
<span class="lineNum">     207 </span>            :     if (*s == dot) {
<span class="lineNum">     208 </span>            :       if (hasdot) break;  /* second dot? stop loop */
<span class="lineNum">     209 </span>            :       else hasdot = 1;
<span class="lineNum">     210 </span>            :     }
<span class="lineNum">     211 </span>            :     else if (lisxdigit(cast_uchar(*s))) {
<span class="lineNum">     212 </span>            :       if (sigdig == 0 &amp;&amp; *s == '0')  /* non-significant digit (zero)? */
<span class="lineNum">     213 </span>            :         nosigdig++;
<span class="lineNum">     214 </span>            :       else if (++sigdig &lt;= MAXSIGDIG)  /* can read it without overflow? */
<span class="lineNum">     215 </span>            :           r = (r * cast_num(16.0)) + luaO_hexavalue(*s);
<span class="lineNum">     216 </span>            :       else e++; /* too many digits; ignore, but still count for exponent */
<span class="lineNum">     217 </span>            :       if (hasdot) e--;  /* decimal digit? correct exponent */
<span class="lineNum">     218 </span>            :     }
<span class="lineNum">     219 </span>            :     else break;  /* neither a dot nor a digit */
<span class="lineNum">     220 </span>            :   }
<span class="lineNum">     221 </span>            :   if (nosigdig + sigdig == 0)  /* no digits? */
<span class="lineNum">     222 </span>            :     return 0.0;  /* invalid format */
<span class="lineNum">     223 </span>            :   *endptr = cast(char *, s);  /* valid up to here */
<span class="lineNum">     224 </span>            :   e *= 4;  /* each digit multiplies/divides value by 2^4 */
<span class="lineNum">     225 </span>            :   if (*s == 'p' || *s == 'P') {  /* exponent part? */
<span class="lineNum">     226 </span>            :     int exp1 = 0;  /* exponent value */
<span class="lineNum">     227 </span>            :     int neg1;  /* exponent signal */
<span class="lineNum">     228 </span>            :     s++;  /* skip 'p' */
<span class="lineNum">     229 </span>            :     neg1 = isneg(&amp;s);  /* signal */
<span class="lineNum">     230 </span>            :     if (!lisdigit(cast_uchar(*s)))
<span class="lineNum">     231 </span>            :       return 0.0;  /* invalid; must have at least one digit */
<span class="lineNum">     232 </span>            :     while (lisdigit(cast_uchar(*s)))  /* read exponent */
<span class="lineNum">     233 </span>            :       exp1 = exp1 * 10 + *(s++) - '0';
<span class="lineNum">     234 </span>            :     if (neg1) exp1 = -exp1;
<span class="lineNum">     235 </span>            :     e += exp1;
<span class="lineNum">     236 </span>            :     *endptr = cast(char *, s);  /* valid up to here */
<span class="lineNum">     237 </span>            :   }
<span class="lineNum">     238 </span>            :   if (neg) r = -r;
<span class="lineNum">     239 </span>            :   return l_mathop(ldexp)(r, e);
<span class="lineNum">     240 </span>            : }
<span class="lineNum">     241 </span>            : 
<span class="lineNum">     242 </span>            : #endif
<span class="lineNum">     243 </span>            : /* }====================================================== */
<span class="lineNum">     244 </span>            : 
<span class="lineNum">     245 </span>            : 
<span class="lineNum">     246 </span>            : /* maximum length of a numeral */
<span class="lineNum">     247 </span>            : #if !defined (L_MAXLENNUM)
<span class="lineNum">     248 </span>            : #define L_MAXLENNUM     200
<span class="lineNum">     249 </span>            : #endif
<span class="lineNum">     250 </span>            : 
<span class="lineNum">     251 </span><span class="lineCov">        244 : static const char *l_str2dloc (const char *s, lua_Number *result, int mode) {</span>
<span class="lineNum">     252 </span>            :   char *endptr;
<span class="lineNum">     253 </span><span class="lineCov">         45 :   *result = (mode == 'x') ? lua_strx2number(s, &amp;endptr)  /* try to convert */</span>
<span class="lineNum">     254 </span><span class="lineCov">        244 :                           : lua_str2number(s, &amp;endptr);</span>
<span class="lineNum">     255 </span><span class="lineCov">        244 :   if (endptr == s) return NULL;  /* nothing recognized? */</span>
<span class="lineNum">     256 </span><span class="lineCov">        188 :   while (lisspace(cast_uchar(*endptr))) endptr++;  /* skip trailing spaces */</span>
<span class="lineNum">     257 </span><span class="lineCov">        186 :   return (*endptr == '\0') ? endptr : NULL;  /* OK if no trailing characters */</span>
<span class="lineNum">     258 </span>            : }
<span class="lineNum">     259 </span>            : 
<span class="lineNum">     260 </span>            : 
<span class="lineNum">     261 </span>            : /*
<span class="lineNum">     262 </span>            : ** Convert string 's' to a Lua number (put in 'result'). Return NULL
<span class="lineNum">     263 </span>            : ** on fail or the address of the ending '\0' on success.
<span class="lineNum">     264 </span>            : ** 'pmode' points to (and 'mode' contains) special things in the string:
<span class="lineNum">     265 </span>            : ** - 'x'/'X' means an hexadecimal numeral
<span class="lineNum">     266 </span>            : ** - 'n'/'N' means 'inf' or 'nan' (which should be rejected)
<span class="lineNum">     267 </span>            : ** - '.' just optimizes the search for the common case (nothing special)
<span class="lineNum">     268 </span>            : ** This function accepts both the current locale or a dot as the radix
<span class="lineNum">     269 </span>            : ** mark. If the convertion fails, it may mean number has a dot but
<span class="lineNum">     270 </span>            : ** locale accepts something else. In that case, the code copies 's'
<span class="lineNum">     271 </span>            : ** to a buffer (because 's' is read-only), changes the dot to the
<span class="lineNum">     272 </span>            : ** current locale radix mark, and tries to convert again.
<span class="lineNum">     273 </span>            : */
<span class="lineNum">     274 </span><span class="lineCov">        244 : static const char *l_str2d (const char *s, lua_Number *result) {</span>
<span class="lineNum">     275 </span>            :   const char *endptr;
<span class="lineNum">     276 </span><span class="lineCov">        244 :   const char *pmode = strpbrk(s, &quot;.xXnN&quot;);</span>
<span class="lineNum">     277 </span><span class="lineCov">        244 :   int mode = pmode ? ltolower(cast_uchar(*pmode)) : 0;</span>
<span class="lineNum">     278 </span><span class="lineCov">        244 :   if (mode == 'n')  /* reject 'inf' and 'nan' */</span>
<span class="lineNum">     279 </span><span class="lineNoCov">          0 :     return NULL;</span>
<span class="lineNum">     280 </span><span class="lineCov">        244 :   endptr = l_str2dloc(s, result, mode);  /* try to convert */</span>
<span class="lineNum">     281 </span><span class="lineCov">        244 :   if (endptr == NULL) {  /* failed? may be a different locale */</span>
<span class="lineNum">     282 </span>            :     char buff[L_MAXLENNUM + 1];
<span class="lineNum">     283 </span><span class="lineCov">         60 :     const char *pdot = strchr(s, '.');</span>
<span class="lineNum">     284 </span><span class="lineCov">         60 :     if (strlen(s) &gt; L_MAXLENNUM || pdot == NULL)</span>
<span class="lineNum">     285 </span><span class="lineCov">         60 :       return NULL;  /* string too long or no dot; fail */</span>
<span class="lineNum">     286 </span><span class="lineNoCov">          0 :     strcpy(buff, s);  /* copy string to buffer */</span>
<span class="lineNum">     287 </span><span class="lineNoCov">          0 :     buff[pdot - s] = lua_getlocaledecpoint();  /* correct decimal point */</span>
<span class="lineNum">     288 </span><span class="lineNoCov">          0 :     endptr = l_str2dloc(buff, result, mode);  /* try again */</span>
<span class="lineNum">     289 </span><span class="lineNoCov">          0 :     if (endptr != NULL)</span>
<span class="lineNum">     290 </span><span class="lineNoCov">          0 :       endptr = s + (endptr - buff);  /* make relative to 's' */</span>
<span class="lineNum">     291 </span>            :   }
<span class="lineNum">     292 </span><span class="lineCov">        184 :   return endptr;</span>
<span class="lineNum">     293 </span>            : }
<span class="lineNum">     294 </span>            : 
<span class="lineNum">     295 </span>            : 
<span class="lineNum">     296 </span>            : #define MAXBY10         cast(lua_Unsigned, LUA_MAXINTEGER / 10)
<span class="lineNum">     297 </span>            : #define MAXLASTD        cast_int(LUA_MAXINTEGER % 10)
<span class="lineNum">     298 </span>            : 
<span class="lineNum">     299 </span><span class="lineCov">       3606 : static const char *l_str2int (const char *s, lua_Integer *result) {</span>
<span class="lineNum">     300 </span><span class="lineCov">       3606 :   lua_Unsigned a = 0;</span>
<span class="lineNum">     301 </span><span class="lineCov">       3606 :   int empty = 1;</span>
<span class="lineNum">     302 </span>            :   int neg;
<span class="lineNum">     303 </span><span class="lineCov">       3608 :   while (lisspace(cast_uchar(*s))) s++;  /* skip initial spaces */</span>
<span class="lineNum">     304 </span><span class="lineCov">       3606 :   neg = isneg(&amp;s);</span>
<span class="lineNum">     305 </span><span class="lineCov">       3702 :   if (s[0] == '0' &amp;&amp;</span>
<span class="lineNum">     306 </span><span class="lineCov">        804 :       (s[1] == 'x' || s[1] == 'X')) {  /* hex? */</span>
<span class="lineNum">     307 </span><span class="lineCov">         96 :     s += 2;  /* skip '0x' */</span>
<span class="lineNum">     308 </span><span class="lineCov">        472 :     for (; lisxdigit(cast_uchar(*s)); s++) {</span>
<span class="lineNum">     309 </span><span class="lineCov">        376 :       a = a * 16 + luaO_hexavalue(*s);</span>
<span class="lineNum">     310 </span><span class="lineCov">        376 :       empty = 0;</span>
<span class="lineNum">     311 </span>            :     }
<span class="lineNum">     312 </span>            :   }
<span class="lineNum">     313 </span>            :   else {  /* decimal */
<span class="lineNum">     314 </span><span class="lineCov">       7669 :     for (; lisdigit(cast_uchar(*s)); s++) {</span>
<span class="lineNum">     315 </span><span class="lineCov">       4159 :       int d = *s - '0';</span>
<span class="lineNum">     316 </span><span class="lineCov">       4159 :       if (a &gt;= MAXBY10 &amp;&amp; (a &gt; MAXBY10 || d &gt; MAXLASTD + neg))  /* overflow? */</span>
<span class="lineNum">     317 </span><span class="lineNoCov">          0 :         return NULL;  /* do not accept it (as integer) */</span>
<span class="lineNum">     318 </span><span class="lineCov">       4159 :       a = a * 10 + d;</span>
<span class="lineNum">     319 </span><span class="lineCov">       4159 :       empty = 0;</span>
<span class="lineNum">     320 </span>            :     }
<span class="lineNum">     321 </span>            :   }
<span class="lineNum">     322 </span><span class="lineCov">       3606 :   while (lisspace(cast_uchar(*s))) s++;  /* skip trailing spaces */</span>
<span class="lineNum">     323 </span><span class="lineCov">       3606 :   if (empty || *s != '\0') return NULL;  /* something wrong in the numeral */</span>
<span class="lineNum">     324 </span>            :   else {
<span class="lineNum">     325 </span><span class="lineCov">       3362 :     *result = l_castU2S((neg) ? 0u - a : a);</span>
<span class="lineNum">     326 </span><span class="lineCov">       3362 :     return s;</span>
<span class="lineNum">     327 </span>            :   }
<span class="lineNum">     328 </span>            : }
<span class="lineNum">     329 </span>            : 
<span class="lineNum">     330 </span>            : 
<span class="lineNum">     331 </span><span class="lineCov">       3606 : size_t luaO_str2num (const char *s, TValue *o) {</span>
<span class="lineNum">     332 </span>            :   lua_Integer i; lua_Number n;
<span class="lineNum">     333 </span>            :   const char *e;
<span class="lineNum">     334 </span><span class="lineCov">       3606 :   if ((e = l_str2int(s, &amp;i)) != NULL) {  /* try as an integer */</span>
<span class="lineNum">     335 </span><span class="lineCov">       3362 :     setivalue(o, i);</span>
<span class="lineNum">     336 </span>            :   }
<span class="lineNum">     337 </span><span class="lineCov">        244 :   else if ((e = l_str2d(s, &amp;n)) != NULL) {  /* else try as a float */</span>
<span class="lineNum">     338 </span><span class="lineCov">        184 :     setfltvalue(o, n);</span>
<span class="lineNum">     339 </span>            :   }
<span class="lineNum">     340 </span>            :   else
<span class="lineNum">     341 </span><span class="lineCov">         60 :     return 0;  /* conversion failed */</span>
<span class="lineNum">     342 </span><span class="lineCov">       3546 :   return (e - s) + 1;  /* success; return string size */</span>
<span class="lineNum">     343 </span>            : }
<span class="lineNum">     344 </span>            : 
<span class="lineNum">     345 </span>            : 
<span class="lineNum">     346 </span><span class="lineCov">         59 : int luaO_utf8esc (char *buff, unsigned long x) {</span>
<span class="lineNum">     347 </span><span class="lineCov">         59 :   int n = 1;  /* number of bytes put in buffer (backwards) */</span>
<span class="lineNum">     348 </span>            :   lua_assert(x &lt;= 0x10FFFF);
<span class="lineNum">     349 </span><span class="lineCov">         59 :   if (x &lt; 0x80)  /* ascii? */</span>
<span class="lineNum">     350 </span><span class="lineCov">          9 :     buff[UTF8BUFFSZ - 1] = cast(char, x);</span>
<span class="lineNum">     351 </span>            :   else {  /* need continuation bytes */
<span class="lineNum">     352 </span><span class="lineCov">         50 :     unsigned int mfb = 0x3f;  /* maximum that fits in first byte */</span>
<span class="lineNum">     353 </span>            :     do {  /* add continuation bytes */
<span class="lineNum">     354 </span><span class="lineCov">        100 :       buff[UTF8BUFFSZ - (n++)] = cast(char, 0x80 | (x &amp; 0x3f));</span>
<span class="lineNum">     355 </span><span class="lineCov">        100 :       x &gt;&gt;= 6;  /* remove added bits */</span>
<span class="lineNum">     356 </span><span class="lineCov">        100 :       mfb &gt;&gt;= 1;  /* now there is one less bit available in first byte */</span>
<span class="lineNum">     357 </span><span class="lineCov">        100 :     } while (x &gt; mfb);  /* still needs continuation byte? */</span>
<span class="lineNum">     358 </span><span class="lineCov">         50 :     buff[UTF8BUFFSZ - n] = cast(char, (~mfb &lt;&lt; 1) | x);  /* add first byte */</span>
<span class="lineNum">     359 </span>            :   }
<span class="lineNum">     360 </span><span class="lineCov">         59 :   return n;</span>
<span class="lineNum">     361 </span>            : }
<span class="lineNum">     362 </span>            : 
<span class="lineNum">     363 </span>            : 
<span class="lineNum">     364 </span>            : /* maximum length of the conversion of a number to a string */
<span class="lineNum">     365 </span>            : #define MAXNUMBER2STR   50
<span class="lineNum">     366 </span>            : 
<span class="lineNum">     367 </span>            : 
<span class="lineNum">     368 </span>            : /*
<span class="lineNum">     369 </span>            : ** Convert a number object to a string
<span class="lineNum">     370 </span>            : */
<span class="lineNum">     371 </span><span class="lineCov">       2636 : void luaO_tostring (lua_State *L, StkId obj) {</span>
<span class="lineNum">     372 </span>            :   char buff[MAXNUMBER2STR];
<span class="lineNum">     373 </span>            :   size_t len;
<span class="lineNum">     374 </span>            :   lua_assert(ttisnumber(obj));
<span class="lineNum">     375 </span><span class="lineCov">       2636 :   if (ttisinteger(obj))</span>
<span class="lineNum">     376 </span><span class="lineCov">       2586 :     len = lua_integer2str(buff, sizeof(buff), ivalue(obj));</span>
<span class="lineNum">     377 </span>            :   else {
<span class="lineNum">     378 </span><span class="lineCov">         50 :     len = lua_number2str(buff, sizeof(buff), fltvalue(obj));</span>
<span class="lineNum">     379 </span>            : #if !defined(LUA_COMPAT_FLOATSTRING)
<span class="lineNum">     380 </span><span class="lineCov">         50 :     if (buff[strspn(buff, &quot;-0123456789&quot;)] == '\0') {  /* looks like an int? */</span>
<span class="lineNum">     381 </span><span class="lineCov">         22 :       buff[len++] = lua_getlocaledecpoint();</span>
<span class="lineNum">     382 </span><span class="lineCov">         22 :       buff[len++] = '0';  /* adds '.0' to result */</span>
<span class="lineNum">     383 </span>            :     }
<span class="lineNum">     384 </span>            : #endif
<span class="lineNum">     385 </span>            :   }
<span class="lineNum">     386 </span><span class="lineCov">       2636 :   setsvalue2s(L, obj, luaS_newlstr(L, buff, len));</span>
<span class="lineNum">     387 </span><span class="lineCov">       2636 : }</span>
<span class="lineNum">     388 </span>            : 
<span class="lineNum">     389 </span>            : 
<span class="lineNum">     390 </span><span class="lineCov">      15200 : static void pushstr (lua_State *L, const char *str, size_t l) {</span>
<span class="lineNum">     391 </span><span class="lineCov">      15200 :   setsvalue2s(L, L-&gt;top, luaS_newlstr(L, str, l));</span>
<span class="lineNum">     392 </span><span class="lineCov">      15200 :   luaD_inctop(L);</span>
<span class="lineNum">     393 </span><span class="lineCov">      15200 : }</span>
<span class="lineNum">     394 </span>            : 
<span class="lineNum">     395 </span>            : 
<span class="lineNum">     396 </span>            : /*
<span class="lineNum">     397 </span>            : ** this function handles only '%d', '%c', '%f', '%p', and '%s'
<span class="lineNum">     398 </span>            :    conventional formats, plus Lua-specific '%I' and '%U'
<span class="lineNum">     399 </span>            : */
<span class="lineNum">     400 </span><span class="lineCov">       4872 : const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {</span>
<span class="lineNum">     401 </span><span class="lineCov">       4872 :   int n = 0;</span>
<span class="lineNum">     402 </span><span class="lineCov">       6477 :   for (;;) {</span>
<span class="lineNum">     403 </span><span class="lineCov">      11349 :     const char *e = strchr(fmt, '%');</span>
<span class="lineNum">     404 </span><span class="lineCov">      11349 :     if (e == NULL) break;</span>
<span class="lineNum">     405 </span><span class="lineCov">       6477 :     pushstr(L, fmt, e - fmt);</span>
<span class="lineNum">     406 </span><span class="lineCov">       6477 :     switch (*(e+1)) {</span>
<span class="lineNum">     407 </span><span class="lineCov">       3809 :       case 's': {  /* zero-terminated string */</span>
<span class="lineNum">     408 </span><span class="lineCov">       3809 :         const char *s = va_arg(argp, char *);</span>
<span class="lineNum">     409 </span><span class="lineCov">       3809 :         if (s == NULL) s = &quot;(null)&quot;;</span>
<span class="lineNum">     410 </span><span class="lineCov">       3809 :         pushstr(L, s, strlen(s));</span>
<span class="lineNum">     411 </span><span class="lineCov">       3809 :         break;</span>
<span class="lineNum">     412 </span>            :       }
<span class="lineNum">     413 </span><span class="lineCov">         16 :       case 'c': {  /* an 'int' as a character */</span>
<span class="lineNum">     414 </span><span class="lineCov">         16 :         char buff = cast(char, va_arg(argp, int));</span>
<span class="lineNum">     415 </span><span class="lineCov">         16 :         if (lisprint(cast_uchar(buff)))</span>
<span class="lineNum">     416 </span><span class="lineCov">         16 :           pushstr(L, &amp;buff, 1);</span>
<span class="lineNum">     417 </span>            :         else  /* non-printable character; print its code */
<span class="lineNum">     418 </span><span class="lineNoCov">          0 :           luaO_pushfstring(L, &quot;&lt;\\%d&gt;&quot;, cast_uchar(buff));</span>
<span class="lineNum">     419 </span><span class="lineCov">         16 :         break;</span>
<span class="lineNum">     420 </span>            :       }
<span class="lineNum">     421 </span><span class="lineCov">        514 :       case 'd': {  /* an 'int' */</span>
<span class="lineNum">     422 </span><span class="lineCov">        514 :         setivalue(L-&gt;top, va_arg(argp, int));</span>
<span class="lineNum">     423 </span><span class="lineCov">        514 :         goto top2str;</span>
<span class="lineNum">     424 </span>            :       }
<span class="lineNum">     425 </span><span class="lineCov">       2062 :       case 'I': {  /* a 'lua_Integer' */</span>
<span class="lineNum">     426 </span><span class="lineCov">       2062 :         setivalue(L-&gt;top, cast(lua_Integer, va_arg(argp, l_uacInt)));</span>
<span class="lineNum">     427 </span><span class="lineCov">       2062 :         goto top2str;</span>
<span class="lineNum">     428 </span>            :       }
<span class="lineNum">     429 </span><span class="lineCov">         50 :       case 'f': {  /* a 'lua_Number' */</span>
<span class="lineNum">     430 </span><span class="lineCov">         50 :         setfltvalue(L-&gt;top, cast_num(va_arg(argp, l_uacNumber)));</span>
<span class="lineNum">     431 </span><span class="lineCov">       2626 :       top2str:  /* convert the top element to a string */</span>
<span class="lineNum">     432 </span><span class="lineCov">       2626 :         luaD_inctop(L);</span>
<span class="lineNum">     433 </span><span class="lineCov">       2626 :         luaO_tostring(L, L-&gt;top - 1);</span>
<span class="lineNum">     434 </span><span class="lineCov">       2626 :         break;</span>
<span class="lineNum">     435 </span>            :       }
<span class="lineNum">     436 </span><span class="lineCov">         12 :       case 'p': {  /* a pointer */</span>
<span class="lineNum">     437 </span>            :         char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */
<span class="lineNum">     438 </span><span class="lineCov">         12 :         void *p = va_arg(argp, void *);</span>
<span class="lineNum">     439 </span><span class="lineCov">         12 :         int l = lua_pointer2str(buff, sizeof(buff), p);</span>
<span class="lineNum">     440 </span><span class="lineCov">         12 :         pushstr(L, buff, l);</span>
<span class="lineNum">     441 </span><span class="lineCov">         12 :         break;</span>
<span class="lineNum">     442 </span>            :       }
<span class="lineNum">     443 </span><span class="lineCov">          6 :       case 'U': {  /* an 'int' as a UTF-8 sequence */</span>
<span class="lineNum">     444 </span>            :         char buff[UTF8BUFFSZ];
<span class="lineNum">     445 </span><span class="lineCov">          6 :         int l = luaO_utf8esc(buff, cast(long, va_arg(argp, long)));</span>
<span class="lineNum">     446 </span><span class="lineCov">          6 :         pushstr(L, buff + UTF8BUFFSZ - l, l);</span>
<span class="lineNum">     447 </span><span class="lineCov">          6 :         break;</span>
<span class="lineNum">     448 </span>            :       }
<span class="lineNum">     449 </span><span class="lineCov">          8 :       case '%': {</span>
<span class="lineNum">     450 </span><span class="lineCov">          8 :         pushstr(L, &quot;%&quot;, 1);</span>
<span class="lineNum">     451 </span><span class="lineCov">          8 :         break;</span>
<span class="lineNum">     452 </span>            :       }
<span class="lineNum">     453 </span><span class="lineNoCov">          0 :       default: {</span>
<span class="lineNum">     454 </span><span class="lineNoCov">          0 :         luaG_runerror(L, &quot;invalid option '%%%c' to 'lua_pushfstring'&quot;,</span>
<span class="lineNum">     455 </span><span class="lineNoCov">          0 :                          *(e + 1));</span>
<span class="lineNum">     456 </span>            :       }
<span class="lineNum">     457 </span>            :     }
<span class="lineNum">     458 </span><span class="lineCov">       6477 :     n += 2;</span>
<span class="lineNum">     459 </span><span class="lineCov">       6477 :     fmt = e+2;</span>
<span class="lineNum">     460 </span>            :   }
<span class="lineNum">     461 </span><span class="lineCov">       4872 :   luaD_checkstack(L, 1);</span>
<span class="lineNum">     462 </span><span class="lineCov">       4872 :   pushstr(L, fmt, strlen(fmt));</span>
<span class="lineNum">     463 </span><span class="lineCov">       4872 :   if (n &gt; 0) luaV_concat(L, n + 1);</span>
<span class="lineNum">     464 </span><span class="lineCov">       4872 :   return svalue(L-&gt;top - 1);</span>
<span class="lineNum">     465 </span>            : }
<span class="lineNum">     466 </span>            : 
<span class="lineNum">     467 </span>            : 
<span class="lineNum">     468 </span><span class="lineCov">        501 : const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {</span>
<span class="lineNum">     469 </span>            :   const char *msg;
<span class="lineNum">     470 </span>            :   va_list argp;
<span class="lineNum">     471 </span><span class="lineCov">        501 :   va_start(argp, fmt);</span>
<span class="lineNum">     472 </span><span class="lineCov">        501 :   msg = luaO_pushvfstring(L, fmt, argp);</span>
<span class="lineNum">     473 </span><span class="lineCov">        501 :   va_end(argp);</span>
<span class="lineNum">     474 </span><span class="lineCov">        501 :   return msg;</span>
<span class="lineNum">     475 </span>            : }
<span class="lineNum">     476 </span>            : 
<span class="lineNum">     477 </span>            : 
<span class="lineNum">     478 </span>            : /* number of chars of a literal string without the ending \0 */
<span class="lineNum">     479 </span>            : #define LL(x)   (sizeof(x)/sizeof(char) - 1)
<span class="lineNum">     480 </span>            : 
<span class="lineNum">     481 </span>            : #define RETS    &quot;...&quot;
<span class="lineNum">     482 </span>            : #define PRE     &quot;[string \&quot;&quot;
<span class="lineNum">     483 </span>            : #define POS     &quot;\&quot;]&quot;
<span class="lineNum">     484 </span>            : 
<span class="lineNum">     485 </span>            : #define addstr(a,b,l)   ( memcpy(a,b,(l) * sizeof(char)), a += (l) )
<span class="lineNum">     486 </span>            : 
<span class="lineNum">     487 </span><span class="lineCov">        505 : void luaO_chunkid (char *out, const char *source, size_t bufflen) {</span>
<span class="lineNum">     488 </span><span class="lineCov">        505 :   size_t l = strlen(source);</span>
<span class="lineNum">     489 </span><span class="lineCov">        505 :   if (*source == '=') {  /* 'literal' source */</span>
<span class="lineNum">     490 </span><span class="lineCov">         70 :     if (l &lt;= bufflen)  /* small enough? */</span>
<span class="lineNum">     491 </span><span class="lineCov">         70 :       memcpy(out, source + 1, l * sizeof(char));</span>
<span class="lineNum">     492 </span>            :     else {  /* truncate it */
<span class="lineNum">     493 </span><span class="lineNoCov">          0 :       addstr(out, source + 1, bufflen - 1);</span>
<span class="lineNum">     494 </span><span class="lineNoCov">          0 :       *out = '\0';</span>
<span class="lineNum">     495 </span>            :     }
<span class="lineNum">     496 </span>            :   }
<span class="lineNum">     497 </span><span class="lineCov">        435 :   else if (*source == '@') {  /* file name */</span>
<span class="lineNum">     498 </span><span class="lineCov">        396 :     if (l &lt;= bufflen)  /* small enough? */</span>
<span class="lineNum">     499 </span><span class="lineCov">        396 :       memcpy(out, source + 1, l * sizeof(char));</span>
<span class="lineNum">     500 </span>            :     else {  /* add '...' before rest of name */
<span class="lineNum">     501 </span><span class="lineNoCov">          0 :       addstr(out, RETS, LL(RETS));</span>
<span class="lineNum">     502 </span><span class="lineNoCov">          0 :       bufflen -= LL(RETS);</span>
<span class="lineNum">     503 </span><span class="lineNoCov">          0 :       memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char));</span>
<span class="lineNum">     504 </span>            :     }
<span class="lineNum">     505 </span>            :   }
<span class="lineNum">     506 </span>            :   else {  /* string; format as [string &quot;source&quot;] */
<span class="lineNum">     507 </span><span class="lineCov">         39 :     const char *nl = strchr(source, '\n');  /* find first new line (if any) */</span>
<span class="lineNum">     508 </span><span class="lineCov">         39 :     addstr(out, PRE, LL(PRE));  /* add prefix */</span>
<span class="lineNum">     509 </span><span class="lineCov">         39 :     bufflen -= LL(PRE RETS POS) + 1;  /* save space for prefix+suffix+'\0' */</span>
<span class="lineNum">     510 </span><span class="lineCov">         39 :     if (l &lt; bufflen &amp;&amp; nl == NULL) {  /* small one-line source? */</span>
<span class="lineNum">     511 </span><span class="lineCov">         29 :       addstr(out, source, l);  /* keep it */</span>
<span class="lineNum">     512 </span>            :     }
<span class="lineNum">     513 </span>            :     else {
<span class="lineNum">     514 </span><span class="lineCov">         10 :       if (nl != NULL) l = nl - source;  /* stop at first newline */</span>
<span class="lineNum">     515 </span><span class="lineCov">         10 :       if (l &gt; bufflen) l = bufflen;</span>
<span class="lineNum">     516 </span><span class="lineCov">         10 :       addstr(out, source, l);</span>
<span class="lineNum">     517 </span><span class="lineCov">         10 :       addstr(out, RETS, LL(RETS));</span>
<span class="lineNum">     518 </span>            :     }
<span class="lineNum">     519 </span><span class="lineCov">         39 :     memcpy(out, POS, (LL(POS) + 1) * sizeof(char));</span>
<span class="lineNum">     520 </span>            :   }
<span class="lineNum">     521 </span><span class="lineCov">        505 : }</span>
<span class="lineNum">     522 </span>            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.13</a></td></tr>
  </table>
  <br>

</body>
</html>
